package Wrapper;

import entity.Orders;
import entity.Ticket;
import entity.Train;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class TicketsWrapper {
    public static ArrayList<Ticket> TicketsWrapper(ResultSet rs, ArrayList<Ticket> ticketsList) throws SQLException {
        Ticket ticket = new Ticket();
        Train train = new Train();
        ticket.setTicketId(rs.getInt(9));
        ticket.setTrainId(rs.getInt(10));
        ticket.setUserId(rs.getInt(11));
        ticket.setSeatType(rs.getString(12));
        ticket.setSeatNumber(rs.getString(13));
        ticket.setPurchaseTime(rs.getDate(14));
        ticket.setStatus(rs.getString(16));
        train.setTrainId(rs.getInt(1));
        train.setTrainName(rs.getString("train_name"));
        train.setDepartureTime(rs.getDate(3));
        train.setArrivalTime(rs.getDate(4));
        train.setStartStation(rs.getString(5));
        train.setEndStation(rs.getString(6));
        ticket.setTrain(train);
        ticketsList.add(ticket);
        return ticketsList;
    }
}
